package com.thinking.project.monitorserver.util;

/**
 * @Description 功能描述： 全局统一响应数据格式基础类
 * @Author tangsixiang@163.com
 * @DATE 2019/6/24 13:07
 * @Version 1.0
 **/

import java.util.HashMap;
import java.util.Map;

public class ResponseData {
    /**
     * @Author tangsixiang
     * @Description 状态码提示语
     * @Date 11:14 2019/7/2
     * @Param
     * @return
     ****/
    private final String message;
    /***
     * @Author tangsixiang
     * @Description    // 返回响应码
     * @Date 11:16 2019/7/2
     * @Param
     * @return
     ****/
    private final int code;
    private final Map<String, Object> data = new HashMap<String, Object>();

    public String getMessage() {
        return message;
    }

    public int getCode() {
        return code;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public ResponseData putDataValue(String key, Object value) {
        data.put(key, value);
        return this;
    }


    public ResponseData(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ResponseData ok() {
        return new ResponseData(200, "Ok");
    }

    public static ResponseData notFound() {
        return new ResponseData(404, "Not Found | token非法入侵，请重新获取！ ");
    }

    public static ResponseData badRequest() {
        return new ResponseData(400, "Bad Request");
    }

    public static ResponseData forbidden() {
        return new ResponseData(403, "Forbidden| 请求数据格式不合法拒绝数据处理");
    }

    public static ResponseData unauthorized() {
        return new ResponseData(401, "unauthorized");
    }

    public static ResponseData serverInternalError() {
        return new ResponseData(500, "Server Internal Error");
    }

    public static ResponseData customerError() {
        return new ResponseData(1001, "customer Error|token值不正确！");
    }

}
